<?php

class allowdenyacces{
    var $permission;
    var $active_pcode;
    var $mastercode;
    
    function allowdenyacces(){
        $odir = getcwd(); $tmp = dirname(__FILE__);
        chdir($tmp); chdir("..");
        $pth = getcwd(); chdir($odir);

        $cfg = parse_ini_file($pth.'/cfg/config.php', 1);
        $this->permission = $cfg['permission'];
        $this->mastercode = 99;
    }
    
    function getPrivileges(){
        return $this->permission;
    } // end getPermissions function
    
    function getActiveCode(){
        return $this->active_pcode;
        
    }//end getActiveCode function
    
    function setActiveCode($permissioncode,$value){
        $this->active_pcode = $permissioncode;
        
    }//end setActiveCode function
    
    function allowdeny($permissioncode = FALSE,$value){
        IF(false == $permissioncode or 0 == $permissioncode or '' == $permissioncode){
            return true;
        }
        $this->active_pcode = $permissioncode;
        $arr = $this->permission;
        $p = split(',',$arr[$permissioncode]);
        if ($permissioncode == $this->mastercode){
            return true;
        }
        else{
            if (in_array($value,$p)){return true;}else {return false;}
        }
        
    } //end allowdeny function

    function setPrivileges($user,$p_value,&$db){
        $db->Exec("");
    }
    
}

#$u = new allowdenyacces();
#echo $u->allowdeny(88,'clients');

?>